﻿IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'GetNumeroFacturaByProveedorIDAndSerie')
	BEGIN
		DROP  Procedure  GetNumeroFacturaByProveedorIDAndSerie
	END

GO

CREATE Procedure GetNumeroFacturaByProveedorIDAndSerie

	(
		@idProveedor int ,
		@serie varchar(10)
	)


AS
begin
SELECT  distinct dbo.Factura.Numero

FROM     dbo.OrdenCompra INNER JOIN
         dbo.Factura ON dbo.OrdenCompra.IdOrdenCompra = dbo.Factura.IdOrdenCompra
where    dbo.OrdenCompra.IdProveedor=@idProveedor and  dbo.Factura.Serie=@serie 
end

GO


GRANT EXEC ON GetNumeroFacturaByProveedorIDAndSerie TO PUBLIC

GO


